package com.younion.action.consumer.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.younion.action.consumer.AbstractRequestConsumer;
import com.younion.action.interactive.mobile.ApiConstant;
import com.younion.action.interactive.mobile.ResultObject;
import com.younion.business.IConfigService;
import com.younion.model.AboutResult;
import com.younion.util.HttpRequestUtils;
import com.younion.util.JsonUtils;
import com.younion.vo.ConfigVO;

public class AboutConsumer extends AbstractRequestConsumer {
	private IConfigService configService = null;

	public IConfigService getConfigService() {
		return configService;
	}

	public void setConfigService(IConfigService configService) {
		this.configService = configService;
	}

	@Override
	public String execute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return getAbout(request, response);
	}

	public String getAbout(HttpServletRequest request,
			HttpServletResponse response) {
		AboutResult aboutResult = new AboutResult();
		List<ConfigVO> configVOList = null;
		ConfigVO configVO = null;
		ResultObject resultObject = new ResultObject();
		Map paramMap = new HashMap();
		paramMap.put("code", "ABOUT");
		try {
			configVOList = (List<ConfigVO>) configService.getByMap(paramMap);
			if (configVOList != null && configVOList.size() > 0) {
				configVO = configVOList.get(0);
				aboutResult.setAbout_html(configVO.getContent());
			}
			resultObject.setResult(aboutResult);
			resultObject.setStatus(ApiConstant.SUCCESS_STATUS);
		} catch (Exception e) {
			resultObject.setStatus(ApiConstant.FALSE_STATUS);
			resultObject.setMsg(ApiConstant.PUBLIC_EXCEPTION);
			e.printStackTrace();
		}
		HttpRequestUtils.printContent(JsonUtils.parseObj2Json(resultObject),
				response);
		return null;
	}

}
